﻿using System;
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Text;
using MTGenome.MTG;

namespace MTGenome.Gatherer
{
    [Table(Name = "Cards"), Export(typeof(ICard)), PartCreationPolicy(CreationPolicy.NonShared)]
    public sealed class Card : ICard
    {
        [Column(IsPrimaryKey = true, CanBeNull = false, DbType = "int NOT NULL")]
        public int MultiverseID
        {
            get;
            set;
        }

        [Column(CanBeNull = false, DbType = "nvarchar(50) NOT NULL")]
        public string Name
        {
            get;
            set;
        }

        [Column(CanBeNull = true, DbType = "nvarchar(50) NULL")]
        public string Artist
        {
            get;
            set;
        }

        [Column(CanBeNull = false, DbType = "nvarchar(20) NOT NULL")]
        public string ManaCost
        {
            get;
            set;
        }

        [Column(CanBeNull = false, DbType = "tinyint NOT NULL")]
        public byte ConvertedManaCost
        {
            get;
            set;
        }

        [Column(CanBeNull = false, DbType = "nvarchar(50) NOT NULL")]
        public string Type
        {
            get;
            set;
        }

        [Column(CanBeNull = false, DbType = "tinyint NOT NULL")]
        public Rarity Rarity
        {
            get;
            set;
        }

        [Column(CanBeNull = false, DbType = "nvarchar(3) NOT NULL")]
        public string Expansion
        {
            get;
            set;
        }

        [Column(CanBeNull = true, DbType = "nvarchar(500) NULL")]
        public string Text
        {
            get;
            set;
        }

        [Column(CanBeNull = true, DbType = "nvarchar(500) NULL")]
        public string FlavorText
        {
            get;
            set;
        }

        [Column(CanBeNull = false, DbType = "tinyint NOT NULL")]
        public Color Color
        {
            get;
            set;
        }

        [Column(CanBeNull = true, DbType = "int NULL")]
        public int? Power
        {
            get;
            set;
        }

        [Column(CanBeNull = true, DbType = "int NULL")]
        public int? Toughness
        {
            get;
            set;
        }

        [Column(CanBeNull = true, DbType = "int NULL")]
        public int? Loyalty
        {
            get;
            set;
        }

        [Column(CanBeNull = true, DbType = "int NULL")]
        public int? CardNumber
        {
            get;
            set;
        }

        [Column(CanBeNull = true, DbType = "nvarchar(20) NULL")]
        public string PowerToughnessText
        {
            get;
            set;
        }

        public string ExpansionName
        {
            get;
            set;
        }

        public int[] OtherMultiverseIDs
        {
            get;
            set;
        }

        public override string ToString()
        {
            return MultiverseID + ": " + Name;
        }
    }
}
